Skip to content

fix(webserver): remove duplicate Date headers in responses#65086

Closed
tysoncung wants to merge 1 commit intoapache:mainfrom
tysoncung:fix/64678-duplicate-date-header
Closed

fix(webserver): remove duplicate Date headers in responses#65086
tysoncung wants to merge 1 commit intoapache:mainfrom
tysoncung:fix/64678-duplicate-date-header

Conversation

@tysoncung
Copy link
Copy Markdown
Contributor

Problem

HTTP responses from the Airflow webserver contain duplicate Date headers. This occurs because both uvicorn (the ASGI server) and Flask (mounted via WSGIMiddleware) each add their own Date header, violating HTTP specifications which require headers to be unique.

Example:

date: Thu, 12 Mar 2026 04:38:44 GMT  <-- from uvicorn
server: uvicorn
...
date: Thu, 12 Mar 2026 04:38:44 GMT  <-- from Flask

Closes #64678

Solution

Added ResponseHeaderDedupMiddleware that:

  • Removes duplicate headers (case-insensitive matching)
  • Keeps only the first occurrence of each header
  • Runs before HttpAccessLogMiddleware to ensure clean responses are logged

Files Changed

  • airflow-core/src/airflow/api_fastapi/core_api/app.py - Added middleware registration
  • airflow-core/src/airflow/api_fastapi/common/response_header_dedup.py - New middleware implementation

Testing

This middleware ensures all responses have unique headers, regardless of whether they come from FastAPI routes or Flask routes mounted via WSGIMiddleware.

)

- Add ResponseHeaderDedupMiddleware to remove duplicate response headers
- Fixes issue where both uvicorn and Flask add Date headers
- Middleware keeps only the first occurrence of each header (case-insensitive)
- Applied before HttpAccessLogMiddleware to ensure clean responses

Closes apache#64678
Copy link
Copy Markdown
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a middleware that will strip out the duplicated headers. Can we instead fix the ASGI app (flask) to not include that unwanted Date header ?

@potiuk potiuk marked this pull request as draft April 22, 2026 18:19
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Apr 22, 2026

@tysoncung Converting to draft — this PR doesn't yet meet our Pull Request quality criteria.

  • Failing CI — broad regression: 10+ checks are failing, including multiple e2e test suites (Regular e2e test, Elasticsearch remote logging e2e, Remote logging e2e, XCom object storage backend e2e), all three K8S System:* executors on 1.30.13, plus Task SDK integration and Airflow CTL integration. The pattern is too broad to be flaky — it looks like the change breaks how deployed tasks see the webserver. Please investigate: start with a local breeze k8s run-complete-tests and the Task SDK integration suite.

See the linked criteria for how to fix each item, then mark the PR "Ready for review". This is not a rejection — just an invitation to bring the PR up to standard. No rush.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.

@potiuk
Copy link
Copy Markdown
Member

potiuk commented May 5, 2026

@tysoncung This draft PR has been inactive for 13 days since the last triage comment and no response from the author. Closing to keep the queue clean.

You are welcome to reopen this PR when you resume work, or to open a new one addressing the issues previously raised. There is no rush — take your time.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.

@potiuk potiuk closed this May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate Date headers in responses

3 participants